package com.qf.spring1227.factoryBean;

import org.apache.ibatis.session.SqlSession;
import org.apache.ibatis.session.SqlSessionFactory;
import org.springframework.beans.factory.FactoryBean;

public class sqlSessionBean implements FactoryBean<SqlSession> {
    private SqlSessionFactory sqlSessionFactory;

    public SqlSessionFactory getSqlSessionFactory() {
        return sqlSessionFactory;
    }

    public void setSqlSessionFactory(SqlSessionFactory sqlSessionFactory) {
        this.sqlSessionFactory = sqlSessionFactory;
    }

    @Override
    public boolean isSingleton() {
        return false;
    }

    @Override
    public SqlSession getObject() throws Exception {

        return sqlSessionFactory.openSession();
    }

    @Override
    public Class<?> getObjectType() {
        return SqlSession.class;
    }
}
